<template>
	<view class="quotation-item">
		<view class="item-left">
			<uni-icons class="head" @click="oprateHandler" :type="checked ? 'checkbox-filled' : 'circle'"
				:color="checked?'#116BFF':''" size="30"></uni-icons>
		</view>
		<view class="item-right" @click="handleItemClick">
			<view class="text">
				<view class="name displayEll">{{data.custom_name}}</view>
				<view class="displayEll">联系人：{{data.custom_contact}}</view>
				<view class="displayEll">材料：{{data.raw}}</view>
				<view class="displayEll">备注：{{data.remark}}</view>
				<view>保存时间：{{dateFormat(data.updated_at)}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	/**
	 * 报价记录
	 * （展示操作区，报价信息）
	 */
	export default {
		name: 'quotationListItem',
		props: {
			data: {
				type: Object,
				default: {},
				required: true,
			}
		},
		data() {
			return {
				checked: false,
			};
		},
		methods: {
			dateFormat(val) {
				if (!val) return ''
				return new Date(val).toLocaleDateString(
					'zh-cn'
				);
			},
			oprateHandler() {
				this.checked = !this.checked
				this.$emit("oprateClick", {
					checked: this.checked,
					data: this.data
				});
			},
			handleItemClick() {
				this.$emit("itemClick", {
					checked: this.checked,
					data: this.data
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.displayEll {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		width: 100%;
	}
	.quotation-item {
		box-sizing: border-box;
		display: flex;
		justify-content: space-between;
		align-items: center;
		padding: 28rpx 0;
		background: #FFFFFF;
		// border-radius: 8rpx;
		font-size: 24rpx;
		font-weight: 400;
		color: #999999;
		line-height: 28rpx;
		border-bottom: 1px solid #E7E7E7;

		&:active {
			background-color: #e9e9eb;
		}
	}

	.item-left {
		display: flex;
		align-items: center;

		.head {
			margin: 0 28rpx;

		}

	}

	.item-right {
		display: flex;
		align-items: center;
		flex: 1;
		overflow: hidden;

		.name {
			line-height: 52rpx;
			font-size: 32rpx;
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 500;
			color: rgba(0, 0, 0, 0.9);
		}

		.text {
			width: 100%;
			// margin-left: 20rpx;
			line-height: 34rpx;
			font-size: 28rpx;
			font-family: Source Han Sans CN, Source Han Sans CN;
			font-weight: 400;
		}
	}
</style>